package com.lvcoding.auth2.auth.shizhan.service.impl;

import com.lvcoding.auth2.auth.shizhan.entity.SysClientDetails;
import com.lvcoding.auth2.auth.shizhan.dao.SysClientDetailsDao;
import com.lvcoding.auth2.auth.shizhan.service.SysClientDetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SysClientDetails)表服务实现类
 *
 * @author wys
 * @since 2022-03-22 18:08:07
 */
@Service
public class SysClientDetailsServiceImpl implements SysClientDetailsService {
    @Resource
    private SysClientDetailsDao sysClientDetailsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param clientId 主键
     * @return 实例对象
     */
    @Override
    public SysClientDetails queryById(String clientId) {
        return this.sysClientDetailsDao.queryById(clientId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<SysClientDetails> queryAllByLimit(int offset, int limit) {
        return this.sysClientDetailsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param sysClientDetails 实例对象
     * @return 实例对象
     */
    @Override
    public SysClientDetails insert(SysClientDetails sysClientDetails) {
        this.sysClientDetailsDao.insert(sysClientDetails);
        return sysClientDetails;
    }

    /**
     * 修改数据
     *
     * @param sysClientDetails 实例对象
     * @return 实例对象
     */
    @Override
    public SysClientDetails update(SysClientDetails sysClientDetails) {
        this.sysClientDetailsDao.update(sysClientDetails);
        return this.queryById(sysClientDetails.getClientId());
    }

    /**
     * 通过主键删除数据
     *
     * @param clientId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String clientId) {
        return this.sysClientDetailsDao.deleteById(clientId) > 0;
    }
}
